import {
  yunPaiPageMUT,
  isSaveXinLMUT,
  setRegisterBitValueSetting,
  setPipe,

  checkConnectResMuT,
  SetisUpdateInYUN,
  setTempDArrayReDO,
  SetIsReDo,
  setConectStatus,

  SetXinDARRTORECODE,
  INIAPP,
  setNJdetetioniData,
  AxiosSeturine,
  AxiosHearrate,
  AxiosUrine,

  SetDetectionResult,
  AxiosOvlation,
  AxiosSetovlation,
  AxiosSETPregnant,
  AxiosPregnant,
  AxiosSetuser,
  SETUSERID,

  OPJCLOSS,
  OPNCLOSS,
  setConnectDeviceId,
  AxiosTdev,
  SetIsUpdateTypeValueC,
  SetMainMUT,
  STOPXINDiNI,
  initXinD,
  getF03StringConnect,
  SETTempDArrayArray,
  SETXinDArray,
  SETReDArray,
  SETTempDArray,
  SETwaitTimeXinDian,
  SETdisplayNJdetetioniData,
  SETUUID,
  OPJCC,
  STARTYJ,
  OPNCC,
  STARTNJ,
  WTGYJ,
  WTGNJ,
  TOTLECALLBACK,
  COMMANTOWRITE,
  setRegisterBitValue,
  setRegister4LowValue,
  setRegister4HighValuebefore,
  setRegister4HighValue,
  setRegister4LowValuebefore,
  SETValueChangeType,
  IniReciver,
  AxiosToData
} from './mutation-types.js'

import Vue from 'vue'
import {setStore, getStore} from '../config/mUtils'
import {ToileInit} from "../Toileto/ToileInit";
import axios from 'axios'
import VueAxios from 'vue-axios'
// import VueResource from 'vue-resource'

axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
Vue.use(VueAxios, axios)
// Vue.use(VueResource)
export default {
  [INIAPP](state){
    window.createConnect = function () {
      // console.log(state.deviceIdStore )
      window.hilink.createBLEConnection(state.deviceIdStore )
    }
    window.onBluetoothAdapterStateChangeCallback = function(resultStr) {
      // console.log(resultStr);
      var data = eval("("+resultStr+")")
      if(data.available==true){
        // console.log('重新连接');
        // setTimeout("window.createConnect()",2000)
        window.hilink.onBLEConnectionStateChange ("connetState")
        var re = window.hilink.getCurrentRegisteredDevice('getCurrentRegisteredDeviceM')
      } else{
        state.ConnectStatus = false
        window.hilink.openBluetoothAdapter()
      }
    }
  },
  [setConnectDeviceId](state,{deviceId}){
    state.deviceIdConnect = deviceId
  },
  [AxiosTdev] (state) {
    window.stringToBytes =function( str ) {
      var ch, st, re = [];
      for (var i = 0; i < str.length; i++ ) {
        ch = str.charCodeAt(i);  // get char
        st = [];                 // set up "stack"
        do {
          st.push( ch & 0xFF );  // push byte to stack
          ch = ch >> 8;          // shift value down by 1 byte
        }
        while ( ch )
        re = re.concat( st.reverse() );
      }
      return re
    }

    // let reqParams = {
    //   domain:'http://www.pooai.cn',
    //   path:'/wx/hwapp/web/index.php?r=site/tdevpro',
    // }
    // window.hilink.requestThirdPartConfig(JSON.stringify(reqParams),'getRCTypeResultCallback')
    // window.getRCTypeResultCallback = response=>{
    //   var responseData = response[1]
    //   var re = responseData.fileData
    //   state.UpdateFileData = re
    // }

    if(window.isIOSdevSETING==true){
      window.getRCTypeResultCallback = response => {
        var resData = eval("("+response+")")
        console.log(resData)
        if(resData.errCode==0){
          var responseData = resData.data[1]
          var re = responseData.fileData
          state.UpdateFileData = re
        } else {
          alert('數據下載失敗')
        }
      }
      let reqParams = {
        domain:'https://www.pooai.cn',
        method:'GET',
        path:'/wx/hwapp/web/index.php?r=site/tdevpro'
      }
      window.hilink.requestThirdPartConfig(JSON.stringify(reqParams),'getRCTypeResultCallback')
    } else{
      Vue.axios.get('https://www.pooai.cn/wx/hwapp/web/index.php?r=site/tdevpro').then((response) => {
        var responseData = response.data[1]
        var re = responseData.fileData
        state.UpdateFileData = re
      })
    }


  },
  [AxiosSetuser] (state) {
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/setuser',
      data: {userid: state.UserID,username:state.UserName}
    }).then((response) => {
          var responseData = response.data[1]
          // console.log(responseData)
        })
  },
  [AxiosPregnant] (state) {
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/pregnant',
      data: {userid: state.UserID}
    }).then((response) => {
      // var responseData = response.data[1]
      state.PregnantARR = response
      // console.log(state.PregnantARR.data)
    })
  },
  [AxiosSETPregnant] (state) {
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/setpregnant',
      data: {userid:state.UserID,DetectionResult:state.DetectionResult}
    }).then((response) => {
      var responseData = response.data[1]
      // console.log(responseData)
    })
  },
  [SetDetectionResult] (state,{DetectionResult}){
    state.DetectionResult = DetectionResult
  },
  [AxiosOvlation] (state) {

    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/ovlation',
      data: {userid: state.UserID}
    }).then((response) => {
      state.OvlationARR = response
      console.log(state.OvlationARR.data)
    })
  },
  [AxiosSetovlation] (state) {
    console.log('AxiosSetovlation')
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/setovlation',
      data: {userid:state.UserID,DetectionResult:state.DetectionResult}
    }).then((response) => {
      var responseData = response.data[1]
      console.log(responseData)
    })
  },

  [AxiosUrine](state){
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/urine',
      data: {userid: state.UserID}
    }).then((response) => {
      state.UrineARR = response
      console.log(response)
      // console.log(state.UrineARR.data)
    })
  },
  [setNJdetetioniData](state,{arrnj}){
    state.NJdetetioniData = arrnj
  },


















  [SetIsUpdateTypeValueC](state,{type}) {
    state.IsUpdateTypeValueC = type
  },

  [setConectStatus](state,{val}){
    state.ConnectStatus = val
    state.ConnectStatusUpdate = val
  },
  [setPipe](state,{val}){
    state.pipei = val
  },
  /**
   *
   * @param state
   */
  [SetMainMUT](state){
    window.setUpdateTypeStatus = function(val){
      state.UpdateTypeStatus = val
    }
    window.setsettingsAlert = function(val){
      state.settingsAlert = val
    }
    window.cleartUpData = function(){
      state.UpdateFileData = ''
      state.yiFaLength = 0
    }
    //直接写入十位数据
    window.sendUpdateCommend = function(address) {
      var cmd_address = address;
      var buffer = new Array();
      buffer[0] = 1;
      buffer[1] = 16;
      buffer[2] = 0;
      buffer[3] = 100;
      buffer[4] = 0;
      buffer[5] = 5;
      buffer[6] = buffer[5] * 2;
      for (var i = 0; i < 10; i++) {
        if (cmd_address < state.UpdateFileData.length) {
          buffer[7 + i] = state.UpdateFileData[cmd_address];
        } else {
          buffer[7 + i] =   255;
        }
        cmd_address = cmd_address + 1;
      }
      var crc = state.calculateCRC(buffer, 17);
      buffer[17] = crc[0];
      buffer[18] = crc[1];

      var deviceId = window.getStorageSync('deviceId')
      var serviceId = window.getStorageSync('serviceId')
      var characteristicId = window.getStorageSync('characteristicId')
      var data = state.writeTo16(buffer)
      console.log('写入'+buffer)
      var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
      // mUpdateCommend.offer(buffer);
    }
    window.SetMAINwriteFunction = function(startd,value){
      var wrTore = state.getF06String(1, startd, value)
      var deviceId = window.getStorageSync('deviceId')
      var serviceId = window.getStorageSync('serviceId')
      var characteristicId = window.getStorageSync('characteristicId')
      var data = window.writeTo16(wrTore)
      console.log('写入'+wrTore)
      window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
    }
    window.jieXICC = function (arrayOfbyte) {
      console.log(arrayOfbyte)
      if (arrayOfbyte[0] == 1) {
        switch (arrayOfbyte[1]) {
          case  6:
            if (arrayOfbyte.length == 8) {
              if (arrayOfbyte[5] == 2) {//芯片擦除成功
                state.yiFaLength = 0
                window.sendUpdateCommend( state.yiFaLength)
                console.log('芯片擦除成功')
              } else if (arrayOfbyte[5] == 6) {//马桶升级成功
                state.UpdateTypeStatus = 1
                state.updataStatusNum = '升级成功！'
              }
            }
            break;
          case 16:
            if (arrayOfbyte.length == 8) {
              if (arrayOfbyte[3] == 100) {//数据写入成功
                if (state.yiFaLength < state.UpdateFileData.length) {
                  state.yiFaLength = state.yiFaLength + 10;
                  // console.log('0000000')
                  window.sendUpdateCommend(state.yiFaLength)
                  // if(state.yiFaLength%300==0){
                  //   console.log(state.yiFaLength)
                  // }
                } else {
                  window.SetMAINwriteFunction(90,6)
                  console.log('发6')
                }
              }
            }
            break;
          case  134:
            if (arrayOfbyte.length == 5) {
              if (arrayOfbyte[2] == 0) {//06校验错误，需要重发
                if (state.yiFaLength == 0) {
                  window.SetMAINwriteFunction(90,2)
                  console.log('发2')
                } else {
                  window.SetMAINwriteFunction(90,6)
                  console.log('发6')
                }
              } else if (arrayOfbyte[2] == 1) {//06擦除错误，请重启马桶重新升级
                window.SetMAINwriteFunction(90,2)
              } else if (arrayOfbyte[2] == 2) {//06最后一包写入错误，请重启马桶重新升级！
                state.updataStatusNum = '请重启马桶重新升级！'
                state.UpdateTypeStatus = 3
              } else if (arrayOfbyte[2] == 3) {
                state.UpdateTypeStatus = 2
                state.updataStatusNum = '----內存泄露,升级失败'
              }
            }
            break;
          case  144:
            if (arrayOfbyte.length == 5) {
              if (arrayOfbyte[2] == 0) {//10校验错误，需要重发
                window.sendUpdateCommend(state.yiFaLength)
                console.log('10校验错误，需要重发')
              } else if (arrayOfbyte[2] == 2) {//10写入错误，请重启马桶重新升级！
                window.sendUpdateCommend(state.yiFaLength)
                console.log('10写入错误，请重启马桶重新升级！')
                state.updataStatusNum = '请重启马桶重新升级！'
                state.UpdateTypeStatus = 3
              }
            }
            break;
        }
      }
    }
    window.ValueChange = function (re) {
        console.log('88999')
        var valueC = eval("(" + re + ")");
        var data = valueC.data;
        var dataArr = readTo10(data);
        console.log(dataArr)
        if (dataArr.length == 0) {
          return
        }
        /** **/
        if(state.IsUpdateTypeValueC==0) {
          if (dataArr[0]==1 && dataArr[1]==6) {
            console.log(dataArr)
            return
          }
          if (state.reciveState === 0) {
            state.reciveLen = dataArr[2] + 5
            state.reciveState = 1
            state.reciveData = new Array
          }
          state.reciveData = state.reciveData.concat(dataArr)
          // if (dataArr.length == 5) {
          if (state.reciveData.length==state.reciveLen) {
            console.log('ccc')
            state.stateData = state.receiver(50, state.reciveData);
            state.reciveLen = 0
            state.reciveState = 0
            state.reciveData = new Array
            if (state.stateEndSet == true) {
              state.stateEndSet = false
            } else {
              state.stateEndSet = true
            }
          }
        } else if(state.IsUpdateTypeValueC==1) {
          var  OOrT = state.receiver(90, dataArr)
          /* */
          if(OOrT[0].data!==1 && OOrT[0].data!==2) {
            //72 发65535
            var wrTore = state.getF06String(1, 72, 65535)
            var deviceId = window.getStorageSync('deviceId')
            var serviceId = window.getStorageSync('serviceId')
            var characteristicId = window.getStorageSync('characteristicId')
            var data = window.writeTo16(wrTore)
            console.log('写入：1，72，65535')
            window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
            window.sleep(1000)

            var wrTore = state.getF03String(1, 90, 1)
            var deviceId = window.getStorageSync('deviceId');
            var serviceId = window.getStorageSync('serviceId');
            var characteristicId = window.getStorageSync('characteristicId');
            var data = window.writeTo16(wrTore);
            console.log('写入：1，90，1')
            window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data, "writeCallback")

          } else if (OOrT[0].data==1){
            //90 发2
            var wrTore = state.getF06String(1, 90, 2)
            var deviceId = window.getStorageSync('deviceId')
            var serviceId = window.getStorageSync('serviceId')
            var characteristicId = window.getStorageSync('characteristicId')
            var data = window.writeTo16(wrTore)
            console.log('写入：1，90，2')
            state.IsUpdateTypeValueC = 2
            window.sleep(1000)
            window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
          }
          /* */
        } else if (state.IsUpdateTypeValueC==2) {
          window.jieXICC(dataArr)
        }
      /** **/

    }
  },
  /**
   *
   * @param state
   */
  [TOTLECALLBACK] (state) {
    window.DArrayToReDArray = function () {
        if (state.TempDArray.length !== 0) {
          state.ReDArray.push(state.TempDArray.pop())
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }
          if (state.TempDArray.length !== 0) {
            state.ReDArray.push(state.TempDArray.pop())
          }

          if(state.ReDArray.length >= window.canvasVWidth){
            state.ReDArray.splice(0,1)
          }
      }
    }
    window.setwaitTimeXinDian = function (IsInit) {
      if (IsInit == 1) {
        state.waitTimeXinDian = 60
      } else {
        state.waitTimeXinDian = state.waitTimeXinDian-1
      }
    }
    window.erTypeState = function (errorType,val) {
      var error = ''
      switch (errorType) {
        case 0:
          error = "接触不良";
          break;
        case 1:
        case 2:
          error = "室颤/室速";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 3:
          error = "R on T";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 4:
          error = "三个或四个连发室早";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 6:
          error = "二连发室早";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 7:
          error = "单个室早";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 8:
          error = "室早二连律";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 9:
          error = "室早三联律";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 10:
          error = "室上心动过速";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;

        case 11:
          error = "心动过缓";
          // state.XinL = val
          // state.XinLArray.push(val)
          break;
        case 13:
          error = "起搏器未捕获";
          break;
        case 14:
          error = "起搏器未起博";
          break;
        case 16:
          error = "漏博";
          break;
        case 20:
          error = "正在学习";
          break;
        case 21:
          error = "未进行心律失常检测";
          break;
        case 22:
          //正常心率
          if (val < 40 || val > 150) {
            error = "接触不良";
          } else {
            error = "心率正常";
            state.XinL = val
            state.XinLArray.push(val)
          }
          break;
        case 24:
          error = "噪声信号";
          break;
        case 25:
          error = "信号幅度过小";
          break;
        default:
          error = "BPM:" + val
          break
      }
      state.XinLStatus = error
      if(error=='接触不良'){

      }else{
        state.xinLResultArray.push(error)
    }
    }

    window.YunjDone =function() {
      //孕检8号寄存器 存入39,读取12-29数据并解析保存
      var pushArr = new Array;
      for(var i=12;i<30;i=i+2) {
        pushArr.push(state.stateData[i].data*65535+state.stateData[i+1].data)
      }
      state.YunjData = pushArr
      // console.log(state.YunjData)

      var wrTore = state.getF06String(1,8,39);
      var deviceId = window.getStorageSync('deviceId');
      var serviceId = window.getStorageSync('serviceId');
      var characteristicId = window.getStorageSync('characteristicId');
      var data = state.writeTo16(wrTore);
      var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
    }

    window.YunjDoneSecond =function() {
      //孕检8号寄存器 存入39,读取12-29数据并解析保存
      var pushArr = new Array
      for(var i=12;i<30;i=i+2) {
        state.YunjData.push(state.stateData[i].data*65535+state.stateData[i+1].data)
      }
    }
    window.getNiaoJianData = function () {
      //尿检,读取13-29数据并解析保存 11组数据
      var pushArr = new Array
      for (var i=13; i<30; i++) {
        pushArr.push(state.stateData[i].data & 0x00ff)
        pushArr.push((state.stateData[i].data & 0xff00) >> 8)
      }
      var result = new Array
      for (var i = 0; i < pushArr.length - 2; i += 3) {
        result.push(pushArr.slice(i, i + 3))
      }
      state.NiaoJianData = result
    }
    window.writeFunction = function (wrTore) {
      var deviceId = window.getStorageSync('deviceId')
      var serviceId = window.getStorageSync('serviceId')
      var characteristicId = window.getStorageSync('characteristicId')
      var data = state.writeTo16(wrTore)
      var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
    }

    window.getStorageSync = function (key) {
      var u = navigator.userAgent;
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

      if (isAndroid==true) {
        var deId = state.deviceIdStore
        var serviceId = "0000ffe0-0000-1000-8000-00805f9b34fb"
        var characteristicId = "0000ffe1-0000-1000-8000-00805f9b34fb"
      } else if(isiOS==true){
        var deId = state.iosUUIDCur
        var serviceId = "ffe0"
        var characteristicId = "ffe1"
      }

      switch (key) {
        case 'deviceId':
          // return state.Duuid
          // return "ED14081B-52B5-544B-A211-45FAE38CE869";
          return deId
        // return deId
        case 'serviceId':
          // return "ffe0"
          return serviceId
        case 'characteristicId':
          //   return "ffe1"
          return characteristicId
      }
    }
    window.getSystemInfoSyncCallBack = function (re) {
      var info = eval("("+re+")")
      console.log(info)
      state.OSType = info.platform
    }

    window.AdapterStateChange = function (re) {
      alert('gggg'+re)
    }
    window.onBluetoothDeviceFoundCallback = function(re){
      var data = eval("("+re+")")
      window.hilink.onBLEConnectionStateChange ("connetState")
      console.log("扫描到的设备:"+data.localName)
      var aaa = true
      if(data.localName==='Pooai-08'){
        state.TempARRDevice.push(data.deviceId)
        // state.iosUUIDCur = data.deviceId
        // console.log("当前P8的uuid："+state.iosUUIDCur)
        // window.hilink.createBLEConnection(state.iosUUIDCur)
      }
    }
    window.onBluetoothAdapterStateChangeCallBack = function(re)
    {
      var data = eval("("+re+")")
      console.log(data)
      if(data.available) {
        window.hilink.onBLEConnectionStateChange ("connetState")
        var re = window.hilink.getCurrentRegisteredDevice('getCurrentRegisteredDeviceM')
      } else {
        state.ConnectStatus = false
      }
    }
    window.getCurrentRegisteredDeviceM = function (re) {
      var data = eval("("+re+")")
      state.deviceIdStore = data.deviceId

      var u = navigator.userAgent;
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

      if (isiOS==true) {
        window.hilink.getBLEDeviceCharacteristics('','','setNotifyIOS')
        var errcode = window.hilink.startBluetoothDevicesDiscovery([],0,0)

        console.log('onBluetoothDeviceFound'+errcode)
        window.hilink.onBluetoothDeviceFound("onBluetoothDeviceFoundCallback");
        clearTimeout(window.setTimeoutDevices)
        window.setTimeoutDevices = setTimeout("window.PeconnectDeal()",2000)

      } else {
        window.hilink.createBLEConnection(state.deviceIdStore)
      }

    }
    window.PeconnectDeal = function(){
      console.log("取到设备数值:"+state.TempARRDevice)
      if (state.TempARRDevice.length==0){
        clearTimeout(window.setTimeoutDevices)
        window.setTimeoutDevices = setTimeout("window.PeconnectDeal()",2000)
        return
      }
      state.iosUUIDCur = state.TempARRDevice.pop()
      console.log("取到设备数值第一个值:"+state.iosUUIDCur)
      window.hilink.createBLEConnection(state.iosUUIDCur)
    }
    window.readBLECallBack = function(re){
      console.log('执行readBLECallBack回调，判断匹配mac地址start')
      var valueC = eval("("+re+")")
      var a=valueC.data
      console.log(a)
      var str6 = a.substr(a.length-6)
      console.log(str6)
      var strr6 = a.substr(0,6)
      console.log(strr6)
      var str = str6[4]+str6[5]+":" + str6[2]+str6[3]+":"+str6[0]+str6[1]+":"+strr6[4]+strr6[5]+":"+strr6[2]+strr6[3]+":"+strr6[0]+strr6[1]
      console.log(str)
      console.log(state.deviceIdStore)
      console.log('执行readBLECallBack回调，判断匹配mac地址')
      if(state.deviceIdStore.toLowerCase()==str.toLowerCase()) {
        state.pipei = true
        console.log('停止扫描')
        var errcode = window.hilink.stopBluetoothDevicesDiscovery()
        state.iosUUIDTrth = state.iosUUIDCur
        console.log('配对成功IOS:成功')
        // window.hilink.getBLEDeviceCharacteristics(state.iosUUIDTrth,'ffe0','setNotifyIOS')

        state.ConnectStatus = true
        window.hilink.onBLECharacteristicValueChange ("ValueChange");

        state.IsConnect==true
      } else {
        console.log('P8匹配失败，关掉连接')
        state.pipei = false
        window.hilink.closeBLEConnection(state.iosUUIDCur)
        window.PeconnectDeal()
      }
    }
    window.connetState = function (re)
    {
      var u = navigator.userAgent;
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      var data = eval("("+re+")")
      if(data.connected==true) {
        if (isiOS==true) {
          console.log('连接到当前设备:'+state.iosUUIDCur)
          sleep(2000)
          window.hilink.readBLECharacteristicValue(state.iosUUIDCur ,"180A","2A23",'readBLECallBack')
        } else {
          console.log('连接状态ANDR:'+data.connected)
          state.ConnectStatus = true
          window.hilink.onBLECharacteristicValueChange ("ValueChange");

          if(state.IsConnect==false) {
            setTimeout("setNotify()", 2000)
          }
          state.IsConnect==true
        }
      } else {
        console.log('连接状态'+data.connected)
        state.ConnectStatus = false
        if (isiOS==true) {
          if(state.pipei==true){
            window.hilink.createBLEConnection(state.iosUUIDTrth)
          }
        }else {
          window.hilink.createBLEConnection(state.deviceIdStore)
        }
      }
    }

    // window.rebuildingValueChange = function () {
    //   window.hilink.onBLECharacteristicValueChange ("ValueChange");
    //   // setNotify()
    //   setTimeout("setNotify()", 1000)
    // }
    window.setNotify = function ()
    {
      var d = new Date()
      var n = d.getTime()
      var deviceId = window.getStorageSync('deviceId')
      var serviceId = window.getStorageSync('serviceId')
      var characteristicId = window.getStorageSync('characteristicId')
      var re = window.hilink.notifyBLECharacteristicValueChange(deviceId,serviceId,characteristicId,true)

      if(re==0) {
        state.showAlertState = false
        console.log('notifyBLECharacteristicValueChange执行成功。error:'+re);
        state.connectEnd = true

        clearInterval(window.setIntervalId)
        state.reciveLen = 0
        state.reciveState = 0
        state.reciveData = new Array
        window.setIntervalId = setInterval("writeInterval()",1000)

        return true
      } else {
        state.showAlertState = true
        console.log('执行失敗:11')
        setTimeout("window.setNotify()",2000)
      }
    }

    window.setNotifyIOS = function (result)
    {
      var deviceId = window.getStorageSync('deviceId')
      var serviceId = window.getStorageSync('serviceId')
      var characteristicId = window.getStorageSync('characteristicId')
      // sleep(1000)
      var re = window.hilink.notifyBLECharacteristicValueChange(deviceId,serviceId,characteristicId,true);

      if(re==0) {
        state.showAlertState = false
        console.log('notifyBLECharacteristicValueChange执行成功...。error:'+re)
        state.connectEnd = true

        clearInterval(window.setIntervalId)
        state.reciveLen = 0
        state.reciveState = 0
        state.reciveData = new Array
        window.setIntervalId = setInterval("writeInterval()",1000)

        return true;
      } else {
        state.showAlertState = true
        console.log('执行失敗:11666');
      }
    }

    window.writeInterval = function()
    {
      if (state.ValueChangType==0) {
        var wrTore = state.getF03String(1, 50, 30)
        console.log("先写入：1,50（起始）,1(一个1位长度)"+wrTore);
      } else if(state.ValueChangType==1) {
        var wrTore = state.getF03String(1, 0, 30)
        console.log("先写入：1,0（起始）,1(一个1位长度)"+wrTore);
      }

      var deviceId = window.getStorageSync('deviceId');
      var serviceId = window.getStorageSync('serviceId');
      var characteristicId = window.getStorageSync('characteristicId');
      var data = state.writeTo16(wrTore);
      window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback")
    }

    window.ValueChange = function (re)
    {
      // state.IsNotify = true;
      var valueC = eval("("+re+")");
      var data = valueC.data;
      var dataArr = state.readTo10(data);

      if (dataArr.length==0) {
        return
      }
      if(state.ValueChangType==0){
        if (dataArr[0]==1 && dataArr[1]==6) {
          console.log(dataArr)
          return
        }
        // console.log(dataArr)
        if( state.reciveState===0) {
          state.reciveLen = dataArr[2]+5
          state.reciveState = 1
          state.reciveData = new Array
        }
        state.reciveData = state.reciveData.concat(dataArr)
        // if (state.reciveData.length==state.reciveLen) {
        if(dataArr.length==5){
          if (state.receiver(50,state.reciveData).length===0){

          } else {
            state.stateData = state.receiver(50,state.reciveData);
          }
          state.reciveLen = 0
          state.reciveState = 0
          state.reciveData = new Array
          if(state.stateEnd == true) {
            state.stateEnd = false
          } else {
            state.stateEnd = true
          }
        }

      } else if(state.ValueChangType==1) {
        if (dataArr[0]==1 && dataArr[1]==6) {
          console.log(dataArr)
          return
        }
        if( state.reciveState===0) {
          state.reciveLen = dataArr[2]+5
          state.reciveState = 1
          state.reciveData = new Array
        }
        state.reciveData = state.reciveData.concat(dataArr)
        if (state.reciveData.length==state.reciveLen) {
        // if (dataArr.length==5) {
          state.stateData = state.receiver(0,state.reciveData);
          state.reciveLen = 0
          state.reciveState = 0
          state.reciveData = new Array
          if(state.stateEnd == true) {
            state.stateEnd = false
          } else {
            state.stateEnd = true
          }
          if(state.YORN=='Y') {
            //判断是否完成检测,yunjian
            if (state.stateData[8].data==38) {
              state.IsYunReDone = 0
              window.YunjDone()
            }

            if(state.stateData[8].data == 40) {
              if(state.YunjData.length==18){
                if(state.IsYunReDone==1) {} else {
                  window.checkYunjToRe(state.YunjData)
                }
                state.IsYunReDone = 1

              } else {
                window.YunjDoneSecond()
              }
            }
          } else if (state.YORN=='N') {
            //判断是否完成检测,尿检
            if (state.stateData[8].data==38) {
              if(state.IsNiaoReDone == 0) {
                window.getNiaoJianData()
                state.IsNiaoReDone = 1
                console.log('0000ISniaojian=1')
              }
              // console.log(state.NiaoJianData)
            }
          }

        }
      } else if (state.ValueChangType == 2 ) {
        if(state.releaseNumZU == 6) {
          state.XinD = state.unreleaseArray[0]
          // console.log(state.unreleaseArray)
          state.releaseNumZU = 0
          window.releaseXD(state.unreleaseArray)
          state.unreleaseArray = new Array
        } else {
          state.unreleaseArray = state.unreleaseArray.concat(dataArr)
          state.releaseNumZU = state.releaseNumZU + 1
          // console.log(state.releaseNumZU)
        }

      }

    }

    window.checkYunjToRe = function (dataList) {
      var min1 = dataList[2];
      for (var i = 2; i < 7; i++) {
        if (min1 > dataList[i]) {
          min1 = dataList[i];
        }
      }

      var min2 = dataList[10];
      for (var i = 10; i < 15; i++) {
        if (min2 > dataList[i]) {
          min2 = dataList[i];
        }
      }

      var max3 = dataList[7];
      for (var i = 7; i < 10; i++) {
        if (max3 < dataList[i]) {
          max3 = dataList[i];
        }
      }

      if (min1 <= max3) {
        if (min2 <= max3) {
          if (max3 - min1 > 12 && max3 - min2 > 12 && Math.abs((max3 - min2)) / (max3 - min1) < 3) {
            var detection_result = 1;
          } else {
            var detection_result = 0;
          }
        } else {
          var detection_result = 0;
        }
      } else {
        if (min2 <= max3) {
          //TODO 有一条杠
          var detection_result = 0;
        } else {
          var detection_result = 2;
        }
      }
      state.DetectionResult = detection_result
      if (state.IsYunjDone == true){
        state.IsYunjDone = false
      } else {
        state.IsYunjDone = true
      }
      console.log('ISyunjDone=truefalse')
    }
    window.sleep = function(numberMillis) {
      var now = new Date();
      var exitTime = now.getTime() + numberMillis;
      while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
          return;
      }
    }
    window.strToArray = function (str) {
      var strsArr= new Array(); //定义一数组
      strsArr = str.split(",")
      return strsArr
    }
    window.writeCallback = function (re) {
      var u = navigator.userAgent;
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

      if (isiOS==true) {
        // var data = eval("("+re+")")
        // if (data.retCode == 90001) {
        //   console.log('AAA')
        //   var deviceId = window.getStorageSync('deviceId')
        //   window.hilink.closeBLEConnection(deviceId)
        //   setTimeout('window.lianjieW()',2000)
        // }
      }
    }

    window.lianjieW = function () {
      var deviceId = window.getStorageSync('deviceId')
      window.hilink.createBLEConnection(deviceId)
    }

    window.getConnectedBluetoothDevicesCallback = function (re) {
      console.log("=======")
      console.log(re)
      console.log("=======")
    }
    window.startYjyc = function () {
      state.YORN = 'Y';//设置孕检接受数据标识
      var wrTore = state.getF06String(1, 8, 2)
      console.log("先写入：1,8（起始）,w2,开始孕期检测"+wrTore)
      window.writeFunction(wrTore)
    }
    window.startPjyc = function () {
      state.YORN = 'Y';//设置孕检接受数据标识
      var wrTore = state.getF06String(1, 8, 3)
      console.log("先写入：1,8（起始）,w2,开始排卵检测"+wrTore)
      window.writeFunction(wrTore)
    }
    window.startNjyc = function () {
      state.IsNiaoReDone = 0 //尿检开启标识
      var wrTore = state.getF06String(1, 8, 1)
      console.log("先写入：1,8（起始）,w1,开始尿检检测"+wrTore)
      window.writeFunction(wrTore)
    }
    window.speakTime = function(val){
      if(state.startJianceTime==val){
        clearInterval(window.startJianceTimeInteval)
      }
      state.startJianceTime += 1
    }
    window.resetStartJianceTime = function(){
      state.startJianceTime = 0
    }

    window.releaseXD = function (buffer) {
      var cmd, val, errorType = 808;

      if (buffer) {
        // var buffer = byteLinkedList.pop();
        var size = buffer.length;
        // console.log('心电：'+size)
        for (var i = 0; i < size - 6; i++) {
          cmd = 0;
          val = 0;
          if (buffer[i] == 1 &&
            (buffer[i + 1] & 0x80) == 0x80 &&
            (buffer[i + 2] & 0x80) == 0x80 &&
            (buffer[i + 3] & 0x80) == 0x80 &&
            buffer[i + 4] == 1) {
            var highbit1 = buffer[i + 1] & 0x01
            var highbit2 = buffer[i + 1] & 0x02 >> 1
            var high = buffer[i + 2] & 0x7f
            var low = ((buffer[i + 3] & 0x70) | (highbit2 << 7)) >> 4
            var isHeartbit = buffer[i + 3] & 0x01
            val = ((highbit1 << 7) | high) * 16 + (low);
            cmd = 69;
            i += 2;
          } else if (buffer[i] == 2 &&
            (buffer[i + 1] & 0x80) == 0x80 &&
            (buffer[i + 2] & 0x80) == 0x80 &&
            (buffer[i + 3] & 0x80) == 0x80 &&
            (buffer[i + 4] & 0x80) == 0x80) {
            var highbit1 = buffer[i + 1] & 0x10 >> 4;
            var highbit2 = buffer[i + 1] & 0x08 >> 3;

            var low = (highbit1 << 7) | (buffer[i + 2] & 0x7f);
            var high = (highbit2 << 7) | (buffer[i + 3] & 0x7f);
            var beat = high * 256 + low;
            if (beat > 30000) {
              val = state.XinD
            } else {
              val = beat;
            }
            // console.log('心电：'+22222)
            errorType = buffer[i + 4] & 0x7f;
            cmd = 79;
            i += 7;
          }
          switch (cmd) {
            case 69: //心电，返回的心电数据
              state.XinD = val
              state.XinDArray.push(val)
              // console.log('心电6666：'+val)
              // resuleLists.add(val);
              // detectionList.add((byte) (val / 128));
              // detectionList.add((byte) (val % 128));
              // count++;
              // if (heartList.size() >= 450) {
              //   heartList.removeFirst();
              //   heartList.addLast((float) val);
              // } else {
              //   heartList.add((float) val);
              // }
              // if (count % 20 == 0) {
              //   count = 0;
              //   mHandler.sendEmptyMessage(1);
              // }
              break;
            case 79:
              window.erTypeState(errorType,val)

              // state.XinL = val
              // state.XinLArray.push(val)

              // console.log('心率555：'+val)
              // Message message = new Message();
              // message.what = 2;
              // message.arg1 = val;
              // message.arg2 = errorType;
              // mHandler.sendMessage(message);
              break;
            default:
              break;
          }
        }

      }

    }

  },
  [OPJCC] (state) {
    state.YORN = 'Y';//设置孕检接受数据标识
    var wrTore = state.getF06String(1, 0, 3)
    console.log("先写入：1,0（起始）,w3"+wrTore)
    window.writeFunction(wrTore)
  },
  [OPNCC] (state) {
    state.YORN = 'N' //设置尿检接受数据标识
    state.NJdetetioniData = new Array
    var wrTore = state.getF06String(1, 0, 1)
    console.log("先写入：1,0（起始）,w1"+wrTore)
    window.writeFunction(wrTore)
  },
  [OPNCLOSS] (state) {
    // state.YORN = 'N' //设置尿检接受数据标识
    state.NJdetetioniData = new Array
    var wrTore = state.getF06String(1, 0, 2)
    console.log("先写入：1,0（起始）,w1"+wrTore)
    window.writeFunction(wrTore)
  },
  [OPJCLOSS] (state) {
    // state.YORN = 'N' //设置尿检接受数据标识
    state.NJdetetioniData = new Array
    var wrTore = state.getF06String(1, 0, 4)
    console.log("先写入：1,0（起始）,w1"+wrTore)
    window.writeFunction(wrTore)
  },
  //写入设置页面单个命令
  [setRegisterBitValueSetting] (state, {stateData, starRag,  regBit,  val}) {
    var curValue = stateData
    if (val == 1)
        curValue |= (1 << regBit)
    else
        curValue &= ~(1 << regBit)
    state.stateData[starRag-50] = curValue
    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);

    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
    return true;
  },

  //写入单个命令
  [setRegisterBitValue] (state, {stateData, starRag,  regBit,  val}) {
    var curValue = state.findData(stateData,starRag);
    if (val == 1)
      curValue |= (1 << regBit);
    else
      curValue &= ~(1 << regBit);

    if (window.IndexPage === false) {
      console.log(stateData)
      var newObj = new Object()
      newObj.starReg = starRag
      newObj.data = curValue
      state.stateData.splice(starRag-50,1,newObj)
      console.log(state.stateData)
    }

    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);

    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
    return true;
  },
  //4-7位 hongGanWenDu
  [setRegister4LowValue](state,{stateData,  starRag,  regValue}) {
    // var curValue = state.findData(stateData,starRag);console.log(stateData+'---------')
    var curValue = (stateData & 0xff0f) | ((regValue << 4) & 0x00f0);
    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);
    console.log(curValue+'设置马桶4-7位的值 zuoDianWenDu')
    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
  },

  //设置马桶12-15位的值 shuiYa shuiWen
  [setRegister4HighValue](state,{stateData,  starRag,  regValue}) {
    // var curValue = state.findData(stateData,starRag);console.log(stateData+'---------')
    var curValue = (stateData & 0x0fff) | ((regValue << 12));
    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);
    console.log(curValue+'设置马桶12-15位的值 zuoDianWenDu')
    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
  },
  //设置马桶8—11位的值 zuoDianWenDu
  [setRegister4HighValuebefore](state,{stateData,  starRag,  regValue}) {
    // var curValue = state.findData(stateData,starRag);console.log(stateData+'---------')
    var curValue = (stateData & 0xf0ff) | ((regValue << 8));
    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);
    console.log(curValue+'设置马桶8—11位的值 zuoDianWenDu')
    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
  },
  //设置马桶0-3位的值 penZuiWeiZhi
  [setRegister4LowValuebefore](state,{stateData,  starRag,  regValue}) {
    // var curValue = state.findData(stateData,starRag);console.log(stateData+'---------')
    var curValue = (stateData & 0xfff0) | ((regValue) & 0x000f);
    var wrTore = state.getF06String(1,starRag,curValue);
    var deviceId = window.getStorageSync('deviceId');
    var serviceId = window.getStorageSync('serviceId');
    var characteristicId = window.getStorageSync('characteristicId');
    var data = state.writeTo16(wrTore);
    console.log(curValue+'设置马桶0-3位的值 penZuiWeiZhi')
    var err = window.hilink.writeBLECharacteristicValue(deviceId, serviceId, characteristicId, data,"writeCallback");
  },
  [SETValueChangeType](state,{num}) {
    state.ValueChangType = num;
  },
  [IniReciver] (state) {
    state.reciveLen = 0
    state.reciveState = 0
    state.reciveData = new Array;
  },
  [AxiosToData] (state) {
    // Vue.axios.get('http://www.pooai.cn/wx/hwapp/web/index.php?r=site/niaoj').then((response) => {
      var str = '[true,[{"id":"1","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"255,236,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u767d\u7ec6\u80de\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:54:37","create_time":"2015-07-17 00:42:28"},{"id":"2","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"255,236,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u767d\u7ec6\u80de\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:54:23","create_time":"2015-07-17 00:42:29"},{"id":"3","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"255,236,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u767d\u7ec6\u80de\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:54:13","create_time":"2015-07-17 00:42:30"},{"id":"4","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"233,200,210,0","n_value":"15cells\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u767d\u7ec6\u80de\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:53:59","create_time":"2015-07-17 00:42:31"},{"id":"5","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"210,182,182,0","n_value":"70cells\\/L","result":"\u5c11\u91cf","order_sn":"2","status":"1","description":"\u767d\u7ec6\u80de\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:53:47","create_time":"2015-07-17 00:42:32"},{"id":"6","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"195,157,168,0","n_value":"125cells\\/L","result":"\u4e2d\u91cf","order_sn":"3","status":"1","description":"\u767d\u7ec6\u80de\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:53:29","create_time":"2015-07-17 00:42:33"},{"id":"7","paper_sn":null,"type":"0","order_num":"1","code":"LEU","color":"165,127,145,0","n_value":"500cells\\/L","result":"\u5927\u91cf","order_sn":"4","status":"1","description":"\u767d\u7ec6\u80de\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:53:10","create_time":"2015-07-17 00:42:34"},{"id":"8","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,236,218,0","n_value":"\u9633\u6027","result":"\u9633\u6027","order_sn":"1","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:50:38","create_time":"2015-07-17 00:44:27"},{"id":"9","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,236,218,0","n_value":"\u9633\u6027","result":"\u9633\u6027","order_sn":"1","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:50:28","create_time":"2015-07-17 00:44:28"},{"id":"10","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,236,218,0","n_value":"\u9633\u6027","result":"\u9633\u6027","order_sn":"1","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:50:08","create_time":"2015-07-17 00:44:29"},{"id":"11","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,255,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:49:44","create_time":"2015-07-17 00:44:30"},{"id":"12","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,255,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:48:31","create_time":"2015-07-17 00:44:31"},{"id":"13","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,255,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:48:12","create_time":"2015-07-17 00:44:32"},{"id":"14","paper_sn":null,"type":"0","order_num":"2","code":"NIT","color":"255,255,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u4e9a\u785d\u9178\u76d0\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:47:52","create_time":"2015-07-17 00:44:33"},{"id":"15","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"240,127,142,0","n_value":"131mol\\/L","result":"+++","order_sn":"3","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:47:20","create_time":"2015-07-17 00:46:15"},{"id":"16","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"240,137,139,0","n_value":"66mol\\/L","result":"++","order_sn":"2","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:46:59","create_time":"2015-07-17 00:46:16"},{"id":"17","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"255,155,142,0","n_value":"33mol\\/L","result":"+","order_sn":"1","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:42:39","create_time":"2015-07-17 00:46:17"},{"id":"18","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"250,163,137,0","n_value":"16mol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:41:54","create_time":"2015-07-17 00:46:18"},{"id":"19","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"250,163,137,0","n_value":"16mol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:41:39","create_time":"2015-07-17 00:46:19"},{"id":"20","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"255,182,145,0","n_value":"3.3mol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:41:23","create_time":"2015-07-17 00:46:20"},{"id":"21","paper_sn":null,"type":"0","order_num":"3","code":"UBG","color":"255,182,145,0","n_value":"3.3mol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u5c3f\u80c6\u539f\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:41:07","create_time":"2015-07-17 00:46:21"},{"id":"22","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"62,158,126,0","n_value":"\u226520.0g\\/L","result":"++++","order_sn":"5","status":"1","description":"\u86cb\u767d\u8d28\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-01 10:45:41","create_time":"2015-07-17 00:53:04"},{"id":"23","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"143,152,145,0","n_value":"3.0g\\/L","result":"+++","order_sn":"4","status":"1","description":"\u86cb\u767d\u8d28\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:40:37","create_time":"2015-07-17 00:53:05"},{"id":"24","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"175,178,156,0","n_value":"1.0g\\/L","result":"++","order_sn":"3","status":"1","description":"\u86cb\u767d\u8d28\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:40:22","create_time":"2015-07-17 00:53:06"},{"id":"25","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"195,194,145,0","n_value":"0.3g\\/L","result":"+","order_sn":"2","status":"1","description":"\u86cb\u767d\u8d28\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:40:07","create_time":"2015-07-17 00:53:07"},{"id":"26","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"223,200,152,0","n_value":"\u5fae\u91cf","result":"\u00b1","order_sn":"1","status":"1","description":"\u86cb\u767d\u8d28\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:39:48","create_time":"2015-07-17 00:53:08"},{"id":"27","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"239,210,163,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u86cb\u767d\u8d28\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:39:31","create_time":"2015-07-17 00:53:09"},{"id":"28","paper_sn":null,"type":"0","order_num":"4","code":"PRO","color":"239,210,163,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u86cb\u767d\u8d28\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:39:20","create_time":"2015-07-17 00:53:10"},{"id":"29","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"85,91,72,0","n_value":"8.5","result":"8.5","order_sn":"6","status":"1","description":"ph\u503c\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:38:43","create_time":"2015-07-17 00:53:51"},{"id":"30","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"90,91,72,0","n_value":"8.0","result":"8.0","order_sn":"5","status":"1","description":"ph\u503c\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:38:24","create_time":"2015-07-17 00:53:52"},{"id":"31","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"180,145,93,0","n_value":"7.5","result":"7.5","order_sn":"4","status":"1","description":"ph\u503c\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:37:53","create_time":"2015-07-17 00:53:53"},{"id":"32","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"195,152,109,0","n_value":"7.0","result":"7.0","order_sn":"3","status":"1","description":"ph\u503c\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:37:15","create_time":"2015-07-17 00:53:54"},{"id":"33","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"239,145,109,0","n_value":"6.5","result":"6.5","order_sn":"2","status":"1","description":"ph\u503c\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:36:58","create_time":"2015-07-17 00:53:55"},{"id":"34","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"231,132,109,0","n_value":"6.0","result":"6.0","order_sn":"1","status":"1","description":"ph\u503c\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:36:41","create_time":"2015-07-17 00:53:56"},{"id":"35","paper_sn":null,"type":"0","order_num":"5","code":"PH","color":"227,124,106,0","n_value":"5.0","result":"5.0","order_sn":"0","status":"1","description":"ph\u503c\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:36:18","create_time":"2015-07-17 00:53:57"},{"id":"36","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"60,72,54,0","n_value":"200cells\\/L","result":"\u5927\u91cf","order_sn":"4","status":"1","description":"\u6f5c\u8840\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:52:38","create_time":"2015-07-17 00:55:27"},{"id":"37","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"96,91,66,0","n_value":"80cells\\/L","result":"\u4e2d\u91cf","order_sn":"3","status":"1","description":"\u6f5c\u8840\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:52:23","create_time":"2015-07-17 00:55:28"},{"id":"38","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"120,109,72,0","n_value":"25cells\\/L","result":"\u5c11\u91cf","order_sn":"2","status":"1","description":"\u6f5c\u8840\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:52:09","create_time":"2015-07-17 00:55:29"},{"id":"39","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"168,137,74,0","n_value":"10cells\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u6f5c\u8840\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:51:56","create_time":"2015-07-17 00:55:30"},{"id":"40","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"168,137,74,0","n_value":"10cells\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u6f5c\u8840\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:51:40","create_time":"2015-07-17 00:55:31"},{"id":"41","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"168,137,74,0","n_value":"10cells\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u6f5c\u8840\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:51:28","create_time":"2015-07-17 00:55:32"},{"id":"42","paper_sn":null,"type":"0","order_num":"6","code":"BLD","color":"255,163,109,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u6f5c\u8840\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:51:12","create_time":"2015-07-17 00:55:33"},{"id":"43","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"180,127,91,0","n_value":"1.030","result":"1.030","order_sn":"6","status":"1","description":"\u6bd4\u91cd\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:35:48","create_time":"2015-07-17 00:56:22"},{"id":"44","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"165,127,91,0","n_value":"1.025","result":"1.025","order_sn":"5","status":"1","description":"\u6bd4\u91cd\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:35:32","create_time":"2015-07-17 00:56:23"},{"id":"45","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"156,119,91,0","n_value":"1.020","result":"1.020","order_sn":"4","status":"1","description":"\u6bd4\u91cd\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:35:17","create_time":"2015-07-17 00:56:24"},{"id":"46","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"135,109,75,0","n_value":"1.015","result":"1.015","order_sn":"3","status":"1","description":"\u6bd4\u91cd\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:34:59","create_time":"2015-07-17 00:56:25"},{"id":"47","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"111,91,72,0","n_value":"1.010","result":"1.010","order_sn":"2","status":"1","description":"\u6bd4\u91cd\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:34:43","create_time":"2015-07-17 00:56:26"},{"id":"48","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"90,77,72,0","n_value":"1.005","result":"1.005","order_sn":"1","status":"1","description":"\u6bd4\u91cd\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:34:26","create_time":"2015-07-17 00:56:27"},{"id":"49","paper_sn":null,"type":"0","order_num":"7","code":"SG","color":"75,77,74,0","n_value":"1.000","result":"1.000","order_sn":"0","status":"1","description":"\u6bd4\u91cd\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:33:59","create_time":"2015-07-17 00:56:28"},{"id":"50","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"114,31,85,0","n_value":"16mmol\\/L","result":"\u5927\u91cf","order_sn":"5","status":"1","description":"\u916e\u4f53\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-03 10:32:11","create_time":"2015-07-17 00:57:54"},{"id":"51","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"120,54,72,0","n_value":"7.8mmol\\/L","result":"\u5927\u91cf","order_sn":"4","status":"1","description":"\u916e\u4f53\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:33:20","create_time":"2015-07-17 00:57:55"},{"id":"52","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"155,85,101,0","n_value":"3.9mmol\\/L","result":"\u4e2d\u91cf","order_sn":"3","status":"1","description":"\u916e\u4f53\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:32:55","create_time":"2015-07-17 00:57:56"},{"id":"53","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"195,119,129,0","n_value":"1.5mmol\\/L","result":"\u5c11\u91cf","order_sn":"2","status":"1","description":"\u916e\u4f53\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:32:39","create_time":"2015-07-17 00:57:57"},{"id":"54","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"225,163,163,0","n_value":"0.5mmol\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u916e\u4f53\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:32:17","create_time":"2015-07-17 00:57:58"},{"id":"55","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"255,236,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u916e\u4f53\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:32:00","create_time":"2015-07-17 00:57:59"},{"id":"56","paper_sn":null,"type":"0","order_num":"8","code":"KET","color":"255,236,236,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u916e\u4f53\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:31:46","create_time":"2015-07-17 00:58:00"},{"id":"57","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,194,212,0","n_value":"100\u00b5mol\\/L","result":"\u5927\u91cf","order_sn":"3","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:31:22","create_time":"2015-07-17 01:01:21"},{"id":"58","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,210,210,0","n_value":"50\u00b5mol\\/L","result":"\u4e2d\u91cf","order_sn":"2","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:31:05","create_time":"2015-07-17 01:01:22"},{"id":"59","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,236,236,0","n_value":"17\u00b5mol\\/L","result":"\u5c11\u91cf","order_sn":"1","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:30:30","create_time":"2015-07-17 01:01:23"},{"id":"60","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,246,246,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:29:56","create_time":"2015-07-17 01:01:24"},{"id":"61","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,255,246,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:29:42","create_time":"2015-07-17 01:01:25"},{"id":"62","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,255,246,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:29:31","create_time":"2015-07-17 01:01:26"},{"id":"63","paper_sn":null,"type":"0","order_num":"9","code":"BIL","color":"255,255,246,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u80c6\u7ea2\u7d20\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:29:12","create_time":"2015-07-17 01:01:27"},{"id":"64","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"105,54,41,0","n_value":"110mmol\\/L","result":"+++","order_sn":"5","status":"1","description":"\u8461\u8404\u7cd6\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:08:03","create_time":"2015-07-17 01:02:55"},{"id":"65","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"135,85,54,0","n_value":"55mmol\\/L","result":"+++","order_sn":"4","status":"1","description":"\u8461\u8404\u7cd6\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:07:49","create_time":"2015-07-17 01:02:56"},{"id":"66","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"156,114,74,0","n_value":"28mmol\\/L","result":"++","order_sn":"3","status":"1","description":"\u8461\u8404\u7cd6\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:07:34","create_time":"2015-07-17 01:02:57"},{"id":"67","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"195,182,127,0","n_value":"14mmol\\/L","result":"+","order_sn":"2","status":"1","description":"\u8461\u8404\u7cd6\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:07:19","create_time":"2015-07-17 01:02:58"},{"id":"68","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"184,218,165,0","n_value":"5.5mmol\\/L","result":"\u5fae\u91cf","order_sn":"1","status":"1","description":"\u8461\u8404\u7cd6\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:07:09","create_time":"2015-07-17 01:02:59"},{"id":"69","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"235,255,255,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u8461\u8404\u7cd6\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:24:47","create_time":"2015-07-17 01:03:00"},{"id":"70","paper_sn":null,"type":"0","order_num":"10","code":"GLU","color":"235,255,255,0","n_value":"\u9634\u6027","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u8461\u8404\u7cd6\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-23 10:17:07","create_time":"2015-07-17 01:03:01"},{"id":"71","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"255,223,176,0","n_value":"5.7mmol\\/L","result":"5.7mmol\\/L","order_sn":"4","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c1\u7ec4\u6821\u51c6\u503c","update_time":"2017-07-31 17:06:14","create_time":"2015-07-17 01:05:07"},{"id":"72","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"210,207,163,0","n_value":"2.8mmol\\/L","result":"2.8mmol\\/L","order_sn":"3","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c2\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:56:41","create_time":"2015-07-17 01:05:08"},{"id":"73","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"112,139,127,0","n_value":"1.4mmol\\/L","result":"1.4mmol\\/L","order_sn":"2","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c3\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:56:21","create_time":"2015-07-17 01:05:09"},{"id":"74","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"53,82,101,0","n_value":"0.6mmol\\/L","result":"0.6mmol\\/L","order_sn":"1","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c4\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:56:05","create_time":"2015-07-17 01:05:10"},{"id":"75","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"47,72,91,0","n_value":"0mmol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c5\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:55:53","create_time":"2015-07-17 01:05:11"},{"id":"76","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"47,72,91,0","n_value":"0mmol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c6\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:55:41","create_time":"2015-07-17 01:05:12"},{"id":"77","paper_sn":null,"type":"0","order_num":"11","code":"VC","color":"47,72,91,0","n_value":"0mmol\\/L","result":"\u6b63\u5e38","order_sn":"0","status":"1","description":"\u7ef4\u751f\u7d20\u7b2c7\u7ec4\u6821\u51c6\u503c","update_time":"2017-03-08 17:55:28","create_time":"2015-07-17 01:05:13"}]]'
      var response = eval("("+str+")")
      console.log(response)
      var responseData = response[1]
      console.log(responseData)
      //77个数据分割11组一组7个
      var apiData = new Array
      for (var i = 0; i <  response[1].length; i += 7) {
        apiData.push(response[1].slice(i, i + 7))
      }

      var NiaoJianData = state.NiaoJianData //蓝牙尿检结果数据
      var theId = new  Array //最小值的id值数组

      for (var i = 0; i < NiaoJianData.length; i++) {
        var rm = NiaoJianData[i][0]
        var gm = NiaoJianData[i][1]
        var bm = NiaoJianData[i][2]
        var sevenArr = apiData[i]
        var min = 99999
        var id = 0

        for (var j = 0; j < sevenArr.length; j++) {
          var NJcolorArrs = window.strToArray(sevenArr[j].color)
          var r = NJcolorArrs[0]
          var g = NJcolorArrs[1]
          var b = NJcolorArrs[2]
          var result = Math.sqrt((r - rm) * (r - rm) + (g - gm) * (g - gm) + (b - bm) * (b - bm))
          if (min > result) {
            min = result
            id = i * 7 + j
          }
        }
        theId.push(id)
      }
      // alert(theId)
      for (var i = 0; i < theId.length; i++) {
        state.NJdetetioniData.push(responseData[theId[i]])
      }

      $.ajax({
        type:  'post',
        url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/seturine',
        data: {userid:state.UserID,NJdetetioniData:state.NJdetetioniData},
        success: function (response) {
          var responseData = response.data[1]
          console.log(responseData)
        }
      })

      console.log('1111111111111---------------')
    // })

  },
  [SETUUID](state,{duuid}) {
    state.Duuid = duuid
  },
  [SETTempDArray](state) {
    // if (state.XinDArray.length !== 0) {
    state.TempDArray = [].concat(state.XinDArray)
    // }
    state.TempDArray.reverse()
  },
  [SETTempDArrayArray](state) {
    state.TempDArray.splice(0,state.TempDArray.length)
  },
  [SETXinDArray](state) {
    state.XinDArray.splice(0,state.XinDArray.length)
    state.ReDArray.splice(0,state.ReDArray.length)
    state.XinLArray.splice(0,state.XinLArray.length)
    state.xinLResultArray.splice(0,state.xinLResultArray.length)

    state.XinLStatus = "接触不良"
    state.XinL = 0
  },
  [SETReDArray](state) {
    state.ReDArray.splice(0,state.ReDArray.length)
    state.Relen = 20000
    window.isFirstSETrELEN = false
  },
  [STOPXINDiNI](state){
    state.XinDArray.splice(0,state.XinDArray.length)
  },
  [getF03StringConnect](state,{d,start,len}){
    return state.getF03String(d,start,len)
  },
  [initXinD] (state) {
    if (state.IniINXinD==false) {
      state.IniINXinD = true
    } else{
      state.IniINXinD = false
    }
  },
  [SETUSERID] (state,{userid,username}) {
    state.UserID = userid
    // state.UserID = 'MDFAMTAwMjQwOTA5QGE5NTVlNTU3NTliaN2QyZDEyOTMzNjE4MGZhN2EzMmMwQDU2NzA0ZThhNmNiaYmJmMjgzMzAxNDZmZDI5MmRjZDFmNTUzYjc0YjNmMDdhNDU4NmQ0ODM4M2Zh'
    state.UserName = username
  },

  [setTempDArrayReDO](state,{cans,rate,chartUrl}){
    state.rate = rate
    state.chartUrl = chartUrl
    state.TempDArray = cans
    state.XinDArray = cans
  },
  [SetIsReDo] (state,{status}){
    state.IsReDo = status
  },

  [AxiosHearrate] (state) {
    axios({
      method: 'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/heartrate',
      data: {userid: state.UserID}
      // data: {userid: 'MDFAMTAwMjQwOTA5QGE5NTVlNTU3NTliaN2QyZDEyOTMzNjE4MGZhN2EzMmMwQDU2NzA0ZThhNmNiaYmJmMjgzMzAxNDZmZDI5MmRjZDFmNTUzYjc0YjNmMDdhNDU4NmQ0ODM4M2Zh'}
    }).then((response) => {
      // var responseData = response.data[1]
      state.HearrateArr = response
      console.log('aaafff')
      console.log(state.HearrateArr.data)
    })
  },
  [SetXinDARRTORECODE] (state) {
    var u = navigator.userAgent
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)

    if (isiOS === true) {
      return
    }

    state.isSaveXinL = true
    state.isSaveReturn = false
    if (state.XinLArray.length !== 0){
      var sum=0
      for (var i = 0; i < state.XinLArray.length; i++) {
        sum += parseInt(state.XinLArray[i])
      }
      var mean = sum / state.XinLArray.length
      console.log(state.XinDArray.length)
    } else {
      var mean = 0
    }

    if (mean == 0) {
      return
    }

    state.IsSaveLoading = true
    if(state.XINDReDoButton===false){
      state.XINDReDoButton = true
    }else{
      state.XINDReDoButton = false
    }
    $.ajax({
      type:  'post',
      url: 'https://www.pooai.cn/wx/hwapp/web/index.php?r=site/setheartrate',
      data: {myxinLPJ: mean, myxinLResultArray: state.xinLResultArray, userid: state.UserID,myXinDArray:state.XinDArray},
      success: function (response) {
        state.IsSaveLoading = false
      }
    })
  },
  [SetisUpdateInYUN](state,{isUpdateInYUN}){
    state.isUpdateInYUN = isUpdateInYUN
  },
  [checkConnectResMuT](state,{val}){
    state.checkConnectRes = val
  },
  [isSaveXinLMUT](state,{val}){
    state.isSaveXinL = val
  },
  [yunPaiPageMUT](state,{val}){
    state.yunPaiPage = val
  }
}
